<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <script src="/js/layui/layui.all.js"></script>
    <script src="/admin/js/token.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="station" class="layui-hide" lay-filter="t"></table>
        </div>

    </div>
</div>
</body>
<script type="text/html" id="tb">
    <div class="layui-container">
        <span class="">终端列表</span>
    </div>
</script>
<script type="text/html" id="sh">
    <input type="button" id="dsh" value="未审核" class="layui-btn layui-btn-sm" lay-event="shenhe" />
</script>
</body>
<script>
        var $ = layui.$;

        var form = layui.form;
        var table = layui.table;

        table.render({
            elem: "#station",
            url: "http://127.0.0.1:8080/admin/terminal/selectTerminalShenhe",
            id: "t",
            toolbar: '#tb',
            cols: [
                [{
                    title: "终端编号",
                    field: "terminal_id",
                    width: "15%",
                    fixed: "left",
                    align: "center"
                }, {
                    title: "IP地址",
                    field: "terminal_ip",
                    width: "15%",
                    align: "center"
                }, {
                    title: "MAC地址",
                    field: "terminal_mac",
                    width: "15%",
                    align: "center"
                }, {
                    title: "房间号",
                    field: "terminal_room",
                    width: "8%",
                    align: "center"
                }, {
                    title: "站点名称",
                    field:"station_type_name",
                    width: "10%",
                    align: "center",
                }, {
                    title: "站点编号",
                    field:"station_bh",
                    width: "10%",
                    align: "center",
                }, {
                    title: "是否在线",
                    field:"terminal_line",
                    width: "10%",
                    align: "center",
                }, {
                    title: "所属分组",
                    field:"terminal_group",
                    width: "10%",
                    align: "center",
                }, {
                    title: "版本",
                    field:"terminal_version_code",
                    width: "5%",
                    align: "center",
                }, {
                    title: "型号",
                    field:"terminal_system_model",
                    width: "5%",
                    align: "center",

                }, {
                    title: "操作",
                    width: "10%",
                    align: "center",
                    fixed:"right",
                    toolbar: "#sh",
                }
                ]
            ],
            page: true,
        });
        //    右侧按钮的的监听事件
        table.on("tool(t)", function(obj) {
            var getdata = obj.data; //获得当前行数据
            var layEvent = obj.event;
            var tr = obj.tr;
            switch(layEvent){
                case"shenhe":
                    var close=layer.confirm("确定审核?",{
                        title:"提示",
                        btn:["确定","取消"],
                        btn1:function(){
                            $.ajax({
                                type: "get",
                                url: "http://127.0.0.1:8080/admin/terminal/editterminalShenhe",
                                async: true,
                                data: {
                                    terminalId: getdata.terminal_id

                                },
                                success: function(res) {
                                    if (res.code == 200) {
                                        $(tr).remove();
                                        layer.close(close);
                                        layer.msg("审核成功",{
                                            icon:1
                                        });
                                        return;
                                    }

                                    layer.msg('修改失败', {
                                        icon: 2
                                    });
                                }
                            })
                        }

                    })

                    break;                   }
        });

</script>

</html>